import { Navigate } from 'react-router-dom'
// lazy 路由懒加载方法 按需引入 Suspense内置组件 当路由未加载完成时暂时fallback中的内容
import {lazy,Suspense} from 'react'
// import Cart from '../views/Cart';
// 使用路由懒加载
// import Home from '../views/Home';
// import Mine from '../views/Mine';
// import Info from '../views/Info';
// import Index from '../views/Index';
// import Login from '../views/Login';
import Loading from '../components/loading'
let Cart = lazy(()=>import("../views/Cart"));
let Home = lazy(()=>import('../views/Home'));
let Mine = lazy(()=>import("../views/Mine"));
let Info = lazy(()=>import("../views/Info"));
let Index = lazy(()=>import("../views/Index"));
let Login = lazy(()=>import("../views/Login"));
let NotFount = lazy(()=>import("../views/NotFount"))
let elements = [
    {
        path:"/index",
        element:<Suspense fallback={<Loading/>}><Index/></Suspense>,
        anthor:false,
        children:[
            {
                path:"home",
                element:<Suspense fallback={<Loading/>}><Home/></Suspense>,
                anthor:false
            },{
                path:"cart",
                element:<Suspense fallback={<Loading/>}><Cart/></Suspense>,
                anthor:true
            },{
                path:"mine",
                element:<Suspense fallback={<Loading/>}><Mine/></Suspense>,
                anthor:true
            },
        ]
    },{
        path:"/info",
        element:<Suspense fallback={<Loading/>}><Info/></Suspense>,
        anthor:true
    },{
        path:"/",
        element:<Navigate to='/index/home'/>,
        anthor:false
    },{
        path:"/login",
        element:<Suspense fallback={<Loading/>}><Login/></Suspense>,
        anthor:false
    },{
        // 当找不到该路由时则展示404
        path:"*",
        element:<Suspense fallback={<Loading/>}><NotFount/></Suspense>,
        anthor:false
    }
]

export default elements;